#ifndef GRUBTHEMEFEATURE_H
#define GRUBTHEMEFEATURE_H

#include <QObject>
#include <QApplication>
#include <QWidget>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QGraphicsView>
#include <QVBoxLayout>
#include <QWheelEvent>
#include <QPainter>
#include <QtMath>
#include <QPushButton>

class GrubGraphicsView : public QGraphicsView {
public:
    explicit GrubGraphicsView(QGraphicsScene* scene);

protected:
    void wheelEvent(QWheelEvent* event) override;
//    void drawBackground(QPainter *painter, const QRectF &rect) override;


};

class GrubEditButton : public QPushButton {
    Q_OBJECT
public:
    GrubEditButton(QWidget *parent = nullptr);

    void setPixmap(const QPixmap& pixmap);
    void showCloseIcon();
    void hideCloseIcon();
    void initializeCloseIconRect();
    void drawCloseIcon(QPainter &painter);
protected:
    void paintEvent(QPaintEvent* event) override;

    void enterEvent(QEvent *event);
    void leaveEvent(QEvent *event);
    void mousePressEvent(QMouseEvent *event);
signals:
    void deleteCustomPic();
    void changePic();
private:
    QRect closeIconRect;
    QPixmap pixmap;
    QPixmap closeIconPixmap;
    QPushButton *subbtn;
};

class GrubImageWidget : public QWidget {
public:
    GrubImageWidget(QWidget *parent = nullptr);
    void updateBackground(const QString& imagePath);
private:
    GrubGraphicsView* graphicsView;

    QGraphicsScene* m_scene;
    QPixmap m_mergedImage;
    QPixmap m_image;
    QGraphicsPixmapItem* m_backgroundItem;

    QPixmap m_overlayPixmap;
    QGraphicsPixmapItem* m_overlayItem;
    QGraphicsProxyWidget* m_proxy;
};

class GrubThemeFeature : public QWidget
{
    Q_OBJECT
public:
    explicit GrubThemeFeature(QWidget *parent = nullptr);

signals:

};

#endif // GRUBTHEMEFEATURE_H
